﻿ 
 

// ******************************************************
// 这段代码是自动生成的
// 修改里面的代码，下次生成的时候会被覆盖
// ******************************************************
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.ServiceModel;
using Sharp.Application;
using Sharp.DataTransferObject;
using Sharp.ServiceContracts;
using Sharp.Infrastructure;
using System.ServiceModel.Activation;
using Sharp.Infrastructure.Search;
using Sharp.Infrastructure.IoC;
using Sharp.Infrastructure.Interfaces;
namespace Sharp.Services
{
	[DebuggerStepThrough]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
	public class UserService : IUserService
	{
		private readonly IUserService _userServiceImpl = ServiceLocator.Instance.GetService<IUserService>();
				public Result CreateUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.CreateUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UpdateUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.UpdateUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SaveUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.SaveUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteUsers(IList<System.Guid> userids)
		{
			try
			{
				return _userServiceImpl.DeleteUsers(userids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ValidateUser(String userName, String password)
		{
			try
			{
				return _userServiceImpl.ValidateUser(userName, password);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean DisableUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.DisableUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean UnlockUser(String userName)
		{
			try
			{
				return _userServiceImpl.UnlockUser(userName);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean EnableUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.EnableUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<UserDTO> GetUserByKey(Guid id)
		{
			try
			{
				return _userServiceImpl.GetUserByKey(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<UserDTO> GetUserByEmail(String email)
		{
			try
			{
				return _userServiceImpl.GetUserByEmail(email);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<UserDTO> GetUserByName(String userName)
		{
			try
			{
				return _userServiceImpl.GetUserByName(userName);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<UserDTO> GetUsersPaged(PagingFeature pf, System.Nullable<System.Guid> userGroupId)
		{
			try
			{
				return _userServiceImpl.GetUsersPaged(pf, userGroupId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void AssignRole(Guid userId, Guid roleId)
		{
			try
			{
				 _userServiceImpl.AssignRole(userId, roleId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void UnassignRole(Guid userId)
		{
			try
			{
				 _userServiceImpl.UnassignRole(userId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<PermissionDTO> GetPermissionByUserName(String username)
		{
			try
			{
				return _userServiceImpl.GetPermissionByUserName(username);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ChangePassword(String username, String oldPassword, String newPassword)
		{
			try
			{
				return _userServiceImpl.ChangePassword(username, oldPassword, newPassword);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ChangePasswordQuestionAndAnswer(String username, String password, String newPasswordQuestion, String newPasswordAnswer)
		{
			try
			{
				return _userServiceImpl.ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<UserDTO> TryLogin(UserDTO userDTO)
		{
			try
			{
				return _userServiceImpl.TryLogin(userDTO);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void SaveLog(String log)
		{
			try
			{
				 _userServiceImpl.SaveLog(log);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public UserLogDTO GetUserLogInfo(Guid id)
		{
			try
			{
				return _userServiceImpl.GetUserLogInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteUserLogs(Guid[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteUserLogs(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<UserLogDTO> GetUserLogPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetUserLogPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result RelationUser(Guid userGroupId, Guid[] userIds)
		{
			try
			{
				return _userServiceImpl.RelationUser(userGroupId, userIds);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UnRelationUser(Guid userGroupId, Guid[] userIds)
		{
			try
			{
				return _userServiceImpl.UnRelationUser(userGroupId, userIds);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SendMessage(MessageDTO model)
		{
			try
			{
				return _userServiceImpl.SendMessage(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DraftMessage(MessageDTO model)
		{
			try
			{
				return _userServiceImpl.DraftMessage(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteMessages(Guid[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteMessages(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public MessageDTO GetMessageInfo(Guid id)
		{
			try
			{
				return _userServiceImpl.GetMessageInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<MessageDTO> GetMessagePaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessagePaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<MessageDTO> GetMessageOutboxPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageOutboxPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<MessageDTO> GetMessageDraftboxPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageDraftboxPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<MessageDTO> GetMessageDustbinPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageDustbinPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<IList<MessageDTO>> NoReadMessages()
		{
			try
			{
				return _userServiceImpl.NoReadMessages();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SendNotice(NoticeDTO model)
		{
			try
			{
				return _userServiceImpl.SendNotice(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteNotices(Guid[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteNotices(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public NoticeDTO GetNoticeInfo(Guid id)
		{
			try
			{
				return _userServiceImpl.GetNoticeInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<IList<NoticeDTO>> NoReadNotices()
		{
			try
			{
				return _userServiceImpl.NoReadNotices();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<NoticeDTO> GetNoticePaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetNoticePaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<PermissionDTO> AllPermissions()
		{
			try
			{
				return _userServiceImpl.AllPermissions();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<PermissionDTO> GetPermissionByGroupId(Guid guid)
		{
			try
			{
				return _userServiceImpl.GetPermissionByGroupId(guid);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SavePermission(IList<System.Guid> ids, String owner, Guid ownerId)
		{
			try
			{
				return _userServiceImpl.SavePermission(ids, owner, ownerId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<PermissionDTO> GetPermissionById(Guid uid)
		{
			try
			{
				return _userServiceImpl.GetPermissionById(uid);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UpdatePermission(IList<PermissionDTO> dtos)
		{
			try
			{
				return _userServiceImpl.UpdatePermission(dtos);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IList<RoleDTO> GetRoles()
		{
			try
			{
				return _userServiceImpl.GetRoles();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public RoleDTO GetRoleByKey(Guid id)
		{
			try
			{
				return _userServiceImpl.GetRoleByKey(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result CreateRoles(RoleDTO roleDTO)
		{
			try
			{
				return _userServiceImpl.CreateRoles(roleDTO);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IList<RoleDTO> UpdateRoles(IList<RoleDTO> roledtos)
		{
			try
			{
				return _userServiceImpl.UpdateRoles(roledtos);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void DeleteRoles(IList<System.Guid> roleIDs)
		{
			try
			{
				 _userServiceImpl.DeleteRoles(roleIDs);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<UserGroupDTO> GetUserGroupPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetUserGroupPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public UserGroupDTO GetUserGroupByKey(Guid id)
		{
			try
			{
				return _userServiceImpl.GetUserGroupByKey(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void CreateUserGroup(UserGroupDTO userGroupDto)
		{
			try
			{
				 _userServiceImpl.CreateUserGroup(userGroupDto);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UpdateUserGroup(UserGroupDTO userGroupDto)
		{
			try
			{
				return _userServiceImpl.UpdateUserGroup(userGroupDto);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SaveUserGroup(UserGroupDTO userGroupDto)
		{
			try
			{
				return _userServiceImpl.SaveUserGroup(userGroupDto);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteUserGroups(IList<System.Guid> userGroupids)
		{
			try
			{
				return _userServiceImpl.DeleteUserGroups(userGroupids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean CheckUserGroupName(String name)
		{
			try
			{
				return _userServiceImpl.CheckUserGroupName(name);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<IEnumerable<UserGroupDTO>> GetUserGroups()
		{
			try
			{
				return _userServiceImpl.GetUserGroups();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
	}
}


